In [9]:
from IPython.html import widgets
from IPython.display import display
from eventful_graph import EventfulGraph, empty_eventfulgraph_hook
from widget_forcedirectedgraph import ForceDirectedGraphWidget, publish_js
publish_js()


Barabasi Albert Graph


In [15]:
import networkx.generators.random_graphs as random_graphs

# Add a listener to the eventful graph's construction method.
# If an eventful graph is created, build and show a widget
# for the graph.
def handle_graph(graph):
    print(graph.graph._sleep)
    popup = widgets.PopupWidget()
    popup.description = "NetworkX Barabasi Albert Graph"
    popup.button_text = "Render Window"
    popup.set_css({
        'width': '420px',
        'height': '350px'}, selector='modal')
    graph_widget = ForceDirectedGraphWidget(graph)
    popup.children = [graph_widget]
    display(popup)
EventfulGraph.on_constructed(handle_graph)

# Replace the empty graph of the networkx classic module with
# the eventful graph type.
random_graphs.empty_graph = empty_eventfulgraph_hook(sleep=0.5)

# Graph!
random_graphs.barabasi_albert_graph(15, 2)


0.5
Out[15]:
<eventful_graph.EventfulGraph at 0x4d90690>